define(function(require, exports, module) {
    'use strict';
    
    var rk = require('rk');


    //recent/history menu link
    var recentAccessType = {
        "account": {
            className: "account",
            url: "/final/account.action?id="
        },
        "agent": {
            className: "agent",
            url: "/final/agent.action?id="
        },
        "terminal": {
            className: "terminal",
            url: "/final/terminal.action?id="
        },
        "campaign": {
            className: "market",
            url: "/final/campaign.action?id="
        },
        "opportunity": {
            className: "opp",
            url: "/final/opportunity.action?id="
        },
        "lead": {
            className: "leads",
            url: "/final/lead.action?id="
        },
        "partner": {
            className: "partner",
            url: "/final/partner.action?id="
        },
        "competitor": {
            className: "enemy",
            url: "/final/competitor.action?id="
        },
        "case": {
            className: "case",
            url: "/case-detail/display-info-tab.action?caseId="
        },
        "contact": {
            className: "contact",
            url: "/final/contact.action?id="
        },
        "order": {
            className: "order",
            url: "/final/order.action?id="
        },
        "customize": {
            className: "customize",
            url: "/final/customize.action?id="
        },
        getByKey: function(key) {
            return this[key] || {};
        }
    };


    //crm report cross data
    var cross_data = [
        'baobiao', 'yibiao', 'forecast', 'record', 'workreportstatistic', 'visitcollect', 'salesanalysis', 'attendance','trackanalysis','checkinmap'
    ];

    var icon_map = {
        'record': 'activityrecord',
        'goal': 'salesgoal',
        'market': 'campaign',
        'yibiao': 'dashboard',
        'baobiao': 'report',
        'sl': 'solution',
        'enemy': 'competitor',
        'wanxue': 'dashboard',
        'workreportstatistic': 'reportaccount',
        'checkinmap': 'trackanalysis'
    };



    $.widget('rk.pageLeftCtrl', {
        unfoldMenu: null,
        foldMenu: null,
        _create: function() {
            var me = this;
            var elem = me.element;

            me.unfoldMenu = $('#pageleft_unfold');
            me.foldMenu = $('#pageleft_fold');

            me._initTip();

            //set menu scroller
            elem.find('#pg_common_menu').parent().beScroll();

            me._initFolding();
            me._initCrmUnit();
            me._initFoldMenu();
        },
        _init: function() {
            var me = this;
            var elem = me.element;

            elem.find('.admin-info').click(function() {
                window.location.href = '/final/user.action?uid=' + window.SESSION.user.id;
            });

            elem.find('a[dataname="workreport_menu"]').text(rk.i18n('WR_MENU_STATISTICS'));

            $(window).on('resize', function() {
                me._showViewMore();
            });

            elem.find('.more-page-menu').click(function() {
                $(this).hide();
                elem.find('#pg_common_menu').closest('div.all-menu').beScrollTo('bottom');
            });

            me._initMenuData();
        },
        _initTip: function() {
            var me = this;
            var elem = me.element;
            elem.find('[title]').beTip({
                dir: 'right'
            });
            $('#pageleft_fold_btn').beTip({
                dir: 'right'
            });
            $('#pageleft_unfold_btn').beTip({
                dir: 'right'
            });
        },
        buildCrmMenu: function(data) {
            var me = this;
            var elem = me.element;

            //me.foldCrmMenu.foldSubMenuCtrl('buildMenu', 'fold_crm_menu', data);
        },
        appendHistoryMenu: function(item) {
            var me = this;
            var elem = me.element;
            //$('#pg_history_menu').append('<li><a href="' + item.link + '" target="_blank" onclick="_hmt.push([\'_trackEvent\', \'nav_menu\', \'history\', \'' + window.SESSION.tenantName + '\'])"><span class="ico ' + item.className + '"></span>' + item.name + '</a></li>');

            $('#pg_history_menu').append('<li><a href="' + item.link + '" target="_blank"><span class="ico ' + item.className + '"></span>' + rk.htmlEscape(item.name) + '</a></li>');

        },
        removeHistoryMenu: function(type, id) {
            var me = this;
            var elem = me.element;

        },
        buildHistoryMenu: function(data) {
            var me = this;
            var elem = me.element;
            $('#pg_history_menu').find('li').remove();

            var formatData = [];
            for (var i = 0; i < data.length; i++) {
                var map = recentAccessType.getByKey(data[i].belong);
                var addItem = {};
                addItem.name = data[i].name;
                addItem.link = map.url + data[i].objectId || ''
                addItem.className = map.className || '';
                // 自定义业务实体最近访问的特殊处理
                if(data[i].belongId && data[i].belongId>999) {
                    addItem.link += '&belongId='+data[i].belongId;
                }
                if (map.className === "market") {
                    addItem.className = "campaign";
                }
                if (map.className === "enemy") {
                    addItem.className = "competitor";
                }
                formatData.push(addItem);
                me.appendHistoryMenu(addItem);
            }
            return formatData;
            //me.foldHistoryMenu.foldSubMenuCtrl('buildMenu', 'fold_history_menu', formatData);
        },
        appendCommonMenu: function(item) {
            var me = this;
            var elem = me.element;

            var active = '';

            $('#pg_common_menu').append('<li menuid="' + item.id + '" ' + active + '><a href="/' + item.link + '"><span></span>' + item.name + '</a></li>');
        },
        removeCommonMenu: function(type, id) {
            var me = this;
            var elem = me.element;

        },
        buildFavoriteMenu: function(data) {
            var me = this;
            var elem = me.element;
            $('#pg_common_menu').find('li').remove();
            for (var i = 0; i < data.length; i++) {
                me.appendCommonMenu(data[i]);
            }

            //me.foldCommonMenu.foldSubMenuCtrl('buildMenu', 'fold_common_menu', data);
        },
        fold: function() {
            var me = this;
            me._fold();
        },
        unfold: function() {
            var me = this;
            me._unfold();
        },
        _initFolding: function() {
            var me = this;
            var elem = me.element;

            $('#pageleft_fold_btn').click(function() {
                me._fold();
                $.postJson("/json/global_menu/fold.action?foldMenu=1").done(function(json) {
                    //console.log(json);
                });
            });
            $('#pageleft_unfold_btn').click(function() {
                me._unfold();
                $.postJson("/json/global_menu/fold.action?foldMenu=0").done(function(json) {
                    //console.log(json);
                });
            });
        },
        _initCrmUnit: function() {
            var me = this;

            var crm_elem1 = me.unfoldMenu.find('.crm-page');

            crm_elem1.find('[data-act="crm_menu_setting"]').parent().click(function(e) {
                e.stopPropagation();
                rk.dialog({
                    title: rk.i18n('PAGE_MENU_MANAGEMENT'),
                    width: 930,
                    height: 600,
                    success: function(contentElem, footerElem) {
                        contentElem.crmMenuDialogCtrl();

                        footerElem.find('[act="save"]').click(function() {
                            var crmSelected = contentElem.crmMenuDialogCtrl('getData');
                            if (crmSelected.length > 0) {
                                //me.buildCrmMenu(crmSelected);
                                me._crmMenuData = crmSelected;
                                me._setCrmMenuData();
                                $('#dialog').dialog('close');
                                me._sendSelectedCrmMenu(crmSelected);
                            } else {
                                rk.noticeError(rk.i18n('PAGE_PLS_SELECT_ONE_MORE'));
                            }
                        });

                        footerElem.find('[act="cancel"]').click(function() {
                            $('#dialog').dialog('close');
                        });

                    },
                    footer: ['cancel', 'save']
                });
            });
        },
        _crm_menu_data: [],
        _sta_menu_data: [],
        _setCrmMenuData: function() {
            var me = this;
            //CRM
            var crm_menu_items = me._crmMenuData ? me._crmMenuData : SESSION.menuItems;
            if (me._crmMenuData) {
                me._crm_menu_data = [];

                for (var i = 0; i < crm_menu_items.length; i++) {
                    var icon = crm_menu_items[i].icon.replace('app_', '');

                    if ($.inArray(icon, cross_data) === -1) {
                        var crm_item = {};
                        crm_item.link = crm_menu_items[i].link;
                        crm_item.name = crm_menu_items[i].name;
                        crm_item.className = icon_map[icon] === undefined ? icon : icon_map[icon];
                        me._crm_menu_data.push(crm_item);
                    }
                }

            } else {
                me._crm_menu_data = [];
                me._sta_menu_data = [];
                me.wanxue_data = [];
                for (var i = 0; i < crm_menu_items.length; i++) {

                    var icon = crm_menu_items[i].icon.replace('app_', '');
                    var item = {};
                    item.link = crm_menu_items[i].link;
                    item.name = crm_menu_items[i].name;
                    item.className = icon_map[icon] === undefined ? icon : icon_map[icon];
                    if (icon == 'wanxue') {
                        me.wanxue_data.push(item);
                    } else {
                        if ($.inArray(icon, cross_data) >= 0) {
                            me._sta_menu_data.push(item);
                        } else {
                            me._crm_menu_data.push(item);
                        }
                    }
                }
                me._crm_menu_data = me.wanxue_data.concat(me._crm_menu_data);
            }
        },
        _initFoldMenu: function() {
            var me = this;
            var elem = me.element;

            if (me.unfoldMenu.find('.count-page').find('.page-link').hasClass('active')) {
                me._countActived = true;
            }
            if (me.unfoldMenu.find('.crm-page').find('.page-link').hasClass('active')) {
                me._crmActived = true;
            }

            //subMenu
            elem.find('.menu-thumbnail-box').find('.menu-thumbnail-content > .menu-thumbnail-body').beScroll();
            elem.find('.menu-thumbnail-box').on('mouseenter', function() {
                clearTimeout(me._hideSubMenuTimer);
            }).on('mouseleave', function() {
                me._doHideSubMenu();
            });

            me._setCrmMenuData();

            me.unfoldMenu.find('.crm-page').on('mouseenter', function() {
                var config = {
                    position: {
                        top: '114px',
                        left: '220px'
                    },
                    title: $(this).find("span").attr("menu-title"),
                    items: me._crm_menu_data,
                    showHeader: false
                };
                me._showSubMenu(config, me.unfoldMenu.find('.crm-page'), 'crm');
            }).on('mouseleave', function() {
                me._hideSubMenu();
            });

            me.foldMenu.find('.crm-page').on('mouseenter', function() {
                var config = {
                    position: {
                        top: '114px',
                        left: '60px'
                    },
                    title: $(this).find("span").attr("menu-title"),
                    items: me._crm_menu_data,
                    showHeader: true
                };
                me._showSubMenu(config, me.foldMenu.find('.crm-page'), 'crm');
            }).on('mouseleave', function() {
                me._hideSubMenu();
            });

            //统计分析
            if (me._sta_menu_data.length > 0) {
                me.unfoldMenu.find('.count-page').on('mouseenter', function() {
                    var config = {
                        position: {
                            top: '164px',
                            left: '220px'
                        },
                        title: rk.i18n('FRAME30_SA'),
                        items: me._sta_menu_data,
                        showHeader: false
                    };
                    me._showSubMenu(config, me.unfoldMenu.find('.count-page'), 'crm');
                }).on('mouseleave', function() {
                    me._hideSubMenu();
                });

                me.foldMenu.find('.count-page').on('mouseenter', function() {
                    var config = {
                        position: {
                            top: '164px',
                            left: '60px'
                        },
                        title: rk.i18n('FRAME30_SA'),
                        items: me._sta_menu_data,
                        showHeader: true
                    };
                    me._showSubMenu(config, me.foldMenu.find('.count-page'), 'crm');
                }).on('mouseleave', function() {
                    me._hideSubMenu();
                });
            }

            //常用
            var common_menu_data = [];
            var favoriteMenuItems = SESSION.favoriteMenuItems;
            for (var j = 0; j < favoriteMenuItems.length; j++) {
                var icon = favoriteMenuItems[j].icon.replace('app_', '');
                var common_item = {};
                common_item.link = favoriteMenuItems[j].link;
                common_item.name = favoriteMenuItems[j].name;
                common_item.className = icon_map[icon] === undefined ? icon : icon_map[icon];
                common_menu_data.push(common_item);
            }

            me.foldMenu.find('[data-act="fold_common_toggle"]').on('mouseenter', function() {
                var config = {
                    position: {
                        top: '250px',
                        left: '60px'
                    },
                    title: rk.i18n('FRAME30__236'),
                    items: common_menu_data,
                    showHeader: true
                };
                me._showSubMenu(config, me.foldMenu.find('[data-act="fold_common_toggle"]'), 'common');
            }).on('mouseleave', function() {
                me._hideSubMenu();
            });
            var applicationData;
            rk.post("/pack/get-all-packs.action",{
                decorator: 'ajaxformat',
                confirm: true
            }).done(function(data){
                applicationData = new Array();
                var appArray = $.parseJSON(data.data.view).data.list;
                for(var i =0;i<appArray.length;i++){
                    var app = appArray[i];
                    var application = new Object();
                    application["class_li"]="";
                    application["link"]="";
                    application["class_i"]=app.icon.substring(11);
                    application["name"]=app.name;
                    application["id"]=app.id;
                    application["target"]="_self";
                    application.click = function(id){
                        rk.post("/pack/save-userSetting.action",{
                            decorator: 'ajaxformat',
                            confirm: true,
                            packId: id
                        }).done(function(data){
                            window.location.href="index.action"
                        })
                    }
                    applicationData.push(application);
                }
                var initHeight = 0;
                if(applicationData.length<=1){
                    var initHeight = 35;
                }else {
                    elem.find('[data-act="pg_application_btn_fold"]').attr("style","");
                    elem.find('[data-act="pg_application_btn"]').attr("style","");
                    me.foldApplicationMenu = elem.find('[data-act="pg_application_btn_fold"]').foldSubMenuCtrl({
                        bottom: '70px',
                        id: 'fold_application_menu',
                        tpl: 'set',
                        title: 'application',
                        applicationData: applicationData
                    });
                    me.unfoldApplicationMenu = elem.find('[data-act="pg_application_btn"]').foldSubMenuCtrl({
                        id: 'unfold_application_menu',
                        left: '100px',
                        tpl: 'unfold_set',
                        title: 'application',
                        applicationData: applicationData
                    });
                }

                me.foldHelpMenu = elem.find('[data-act="pg_help_btn_fold"]').foldSubMenuCtrl({
                    bottom: (initHeight+35)+'px',
                    id: 'fold_help_menu',
                    tpl: 'set',
                    title: 'help'
                });
                me.foldSettingMenu = elem.find('[data-act="pg_setting_btn_fold"]').foldSubMenuCtrl({
                    bottom: initHeight + 'px',
                    id: 'fold_setting_menu',
                    tpl: 'set'
                });
            });



            me.unfoldHelpMenu = elem.find('[data-act="pg_help_btn"]').foldSubMenuCtrl({
                id: 'unfold_help_menu',
                left: '50px',
                tpl: 'unfold_set',
                title: 'help'
            });
            me.unfoldSettingMenu = elem.find('[data-act="pg_setting_btn"]').foldSubMenuCtrl({
                id: 'unfold_setting_menu',
                left: '0px',
                tpl: 'unfold_set'
            });
        },
        _initMenuData: function() {
            var me = this;
            var elem = me.element;

            if (elem.find('#pg_history_menu').length > 0) {
                //get recent
                var recent_items_data = null;
                $.postJson("/json/global_frame/recent-access.action").done(function(json) {
                    if (json.status === 0) {
                        var recentItems = json.data.recentAccessList;
                        if (recentItems.length !== 0) {
                            recent_items_data = me.buildHistoryMenu(recentItems);
                            elem.find('#pg_history_menu').show();
                            elem.find('#pg_history_menu').prev().show();
                        }
                    }
                });
                me.foldMenu.find('[data-act="fold_history_toggle"]').on('mouseenter', function() {
                    var config = {
                        position: {
                            top: '300px',
                            left: '60px'
                        },
                        title: rk.i18n('FRAME30__237'),
                        items: recent_items_data,
                        showHeader: true
                    };
                    me._showSubMenu(config, me.foldMenu.find('[data-act="fold_history_toggle"]'), 'history');
                }).on('mouseleave', function() {
                    me._hideSubMenu();
                });
                me._showViewMore();
            } else {
                var oaItems = window.SESSION.oaMenuItems;
                var hasAnnocement = false;
                for (var i = 0; i < oaItems.length; i++) {
                    if (oaItems[i].name === 'announcement') {
                        hasAnnocement = true;
                        break;
                    }
                }
                if (hasAnnocement) {
                    elem.find('.work-menu').find('li.menu_annocement').show();
                }
                me._bindOAEvent();
            }
        },
        _sendSelectedCrmMenu: function(data) {
            var me = this;
            var post_data = [];
            for (var i = 0; i < data.length; i++) {
                var crm_menu = {};
                crm_menu.id = data[i].id;
                crm_menu.checked = true;
                post_data.push(crm_menu);
            }

            $.postJson("/json/global_menu/save.action", {
                menuItems: JSON.stringify(post_data)
            }).done(function(json) {
                //console.log(json);
            });
        },
        isFolding: function() {
            var me = this;
            var elem = me.element;
            return !$('#pageleft_unfold').is(':visible');
        },
        _fold: function() {
            var me = this;
            var opt = me.options;
            $('#pageleft_unfold >div').animate({
                opacity: 0
            }, +100, function() {});
            $('#pageleft_unfold').animate({
                width: '60px'
            }, 200, function() {
                $('#pageleft_unfold').hide();
                $("#pageleft_fold").show().find(">div").css('opacity', 0).animate({
                    opacity: 1
                }, +100);
            });
            $('.main-content').animate({
                left: 60
            }, 200, function() {
                if (opt.onFold) opt.onFold();
                if (opt.onSysFold) opt.onSysFold();
                $(window).trigger('resize');
            });
        },
        _unfold: function() {
            var me = this;
            var elem = me.element;
            var opt = me.options;
            $("#pageleft_fold").find(">div").animate({
                opacity: 0
            }, +100, function() {
                $("#pageleft_fold").hide();
                $('#pageleft_unfold').show().animate({
                        width: 220
                    }, 200)
                    .find(">div").css('opacity', 0).animate({
                        opacity: 1
                    }, +100);
                $('.main-content').animate({
                    left: 220
                }, 200, function() {
                    if (opt.onUnfold) opt.onUnfold();
                    if (opt.onSysUnFold) opt.onSysUnFold();
                    $(window).trigger('resize');
                });
            });
        },
        _bindOAEvent: function() {
            var me = this;
            var elem = me.element;
            elem.find('.create-task').parent().click(function() {
                require.async('oa/js/schedule/asset/utils/scheduleUtil', function(scheduleUtil) {
                    scheduleUtil.popupEditor({
                        isAllDay: false,
                        act: 'create',
                        ownerUser: SESSION.user
                    });
                });
            });

            elem.find('.submit-report').parent().click(function() {
                require.async('core/services/2.0/rk_workreportService', function() {
                    workreportService.getInitInfo(function(data) {
                        var info = workreportService.getBelongTypeInfoByType('day');
                        var belongTypeId = info.id;

                        workreportService.popupEditor({
                            editorAct: 'create',
                            editorType: 'day',
                            belongTypeId: belongTypeId
                        });
                    });
                });
            });

            elem.find('.submit-approval').parent().click(function() {
                require.async('oa/js/approval/dialogs/createDialogCtrl', function() {
                    rk.dialog({
                        title: rk.i18n('APPROVAL_SUBMIT_NEW'),
                        success: function(dialogElem) {
                            dialogElem.createApprovalDialogCtrl();
                        },
                        footer: [{
                            act: 'cancelSubmit',
                            color: 'white',
                            visible: true,
                            text: rk.i18n('CANCEL')
                        }, {
                            act: 'submitApproval',
                            visible: true,
                            text: rk.i18n('SUBMIT')
                        }]
                    });
                });
            });

            elem.find('.send-message').parent().click(function() {
                require.async('oa/js/announcement/dialogs/announcementCreateDialogCtrl', function() {
                    rk.dialog({
                        title: rk.i18n('PAGE_CREATE_NOTICEMENT'),
                        success: function(contentElem) {
                            contentElem.announcementCreateDialogCtrl(); //初始化弹框内容的Ctrl
                        },
                        footer: ['cancel', {
                            act: 'ok',
                            visible: true,
                            text: rk.i18n('SAVE')
                        }]
                    });
                });
            });
        },
        updateUserPic: function(iconPath) {
            var me = this;
            var elem = me.element;
            elem.find('div.admin-info').find('img').attr('src', iconPath);
        },
        _showSubMenu: function(config, el, _hmt_type) {
            var me = this;
            var elem = me.element;

            if (me._hideSubMenuTimer) {
                clearTimeout(me._hideSubMenuTimer);
            }
            me._doHideSubMenu();

            var subMenu = elem.find('.menu-thumbnail-box');

            // set position
            subMenu.css('left', config.position.left);
            if (config.position.top) {
                subMenu.css('top', config.position.top);
            }
            if (config.position.bottom) {
                subMenu.css('bottom', config.position.bottom);
            }
            //render items
            var menuList = subMenu.find('.menu-thumbnail-list');
            menuList.html('');
            if (config.items && config.items.length > 0) {
                for (var i = 0; i < config.items.length; i++) {
                    var item = config.items[i];
                    var itemLink = item.link;
                    var itemTarget = "_blank";
                    if (item.link.slice(0, 1) !== '/') {
                        itemLink = '/' + item.link;
                        itemTarget = "_self";
                    }
                    if (item.link === "workreportstatistic.action") {
                        itemLink = '/workreport.action';
                    }

                    if (item.link === "wanxue.action") {
                        itemLink = '/wxreport.action';
                    }
                    //crm ,common, history
                    //menuList.append('<li><a target="' + itemTarget + '" href="' + itemLink + '" onclick="_hmt.push([\'_trackEvent\', \'nav_menu\', \'' + _hmt_type + '\', \'' + window.SESSION.tenantName + '\'])"><span class="ico ' + item.className + '"></span>' + item.name + '</a></li>');
                    menuList.append('<li><a target="' + itemTarget + '" href="' + itemLink + '"><span class="ico ' + item.className + '"></span>' + rk.htmlEscape(item.name) + '</a></li>');
                }
            }

            subMenu.find('.menu-thumbnail-content > .menu-thumbnail-header').find('h5').html(config.title);
            if (!config.showHeader) {
                subMenu.find('.menu-thumbnail-content > .menu-thumbnail-header').hide();
            } else {
                subMenu.find('.menu-thumbnail-content > .menu-thumbnail-header').show();
            }

            subMenu.show();

            el.find('.page-link').addClass('active');
            el.parent().addClass('active');
        },
        _hideSubMenu: function() {
            var me = this;

            me._hideSubMenuTimer = setTimeout(function() {
                me._doHideSubMenu();
            }, 200);
        },
        _doHideSubMenu: function() {
            var me = this;
            var elem = me.element;

            var subMenu = elem.find('.menu-thumbnail-box');

            subMenu.hide();

            if (!me._countActived) {
                me.unfoldMenu.find('.count-page').find('.page-link').removeClass('active');
                me.foldMenu.find('.count-page').find('.page-link').removeClass('active');
            }
            if (!me._crmActived) {
                me.unfoldMenu.find('.crm-page').find('.page-link').removeClass('active');
                me.foldMenu.find('.crm-page').find('.page-link').removeClass('active');
            }
            me.foldMenu.find('[data-act="fold_history_toggle"]').parent().removeClass('active');
            me.foldMenu.find('[data-act="fold_common_toggle"]').parent().removeClass('active');
        },
        _showViewMore: function() {
            var me = this;
            var elem = me.element;

            var content_height = elem.find("div.all-menu.shortcut-menu.mCustomScrollbar").find('.mCSB_container').height();
            var container_height = elem.find("div.all-menu.shortcut-menu.mCustomScrollbar").find('.mCSB_draggerContainer').height();

            if (elem.find("div.all-menu.shortcut-menu.mCustomScrollbar").find('.mCSB_draggerContainer').is(':visible') && content_height - container_height > 60) {
                elem.find('.more-page-menu').show();
            } else {
                elem.find('.more-page-menu').hide();
            }
        },
        setLogo: function(url) {
            var me = this;
            var elem = me.element;
            elem.find('span.logo-pic').attr('style', 'background-image:url('+url+') !important')//.css('background-image', ''+SESSION.resDomain + url+' !important');
        },
        getLogo: function() {
            var url = this.element.find('span.logo-pic').css('background-image');
            url = url.replace(/^url\(["']?/, '').replace(/["']?\)$/, '');
            return url;
        },
        setLog: function(url) {
            var me = this;
            var elem = me.element;
            elem.find('span.logo-pic').attr('style', 'background-image:url('+url+') !important')//.css('background-image', ''+SESSION.resDomain + url+' !important');
        },
        getLog: function() {
            var url = this.element.find('span.logo-pic').css('background-image');
            url = url.replace(/^url\(["']?/, '').replace(/["']?\)$/, '');
            return url;
        }
    });
});